<?php
	
function display_login(){

	?>
<div id="loggin" style="padding-top:30px;display:none;height:80%;background-color:#fff">
    <center>Please wait!!!<br><br>While we load your updates!!!</center>
</div>
     <div id="divform" style="padding-top:0px;height:100%;">
     <center>
     <div style="padding-top:0%;font-family: Verdana, Geneva, sans-serif;font-size: 12px;">
		<form method="post" action="pages/commuinity.php" name="login">	
		<table width=390 height=285 border=0>
		<tr width=390 height=120 align=center>
			<td align=center colspan=3>
                		<img src="images/community/community.png" alt="">
			</td>
		</tr>
		<tr width=390 height=20 align=center>
			<td align=right width=130> 
				Username:  
			</td>
			<td align=left width=145> 
				<input type="text" id="username" name="username" value="" size=20 class="textbox">
			</td>
		</tr>
		<tr width=390 height=20 align=center>	
			<td align=right width=130>
				Password:
			</td>
			<td align=left width=145>			
				<input type="password" id="pass" name="pass" size=20 class="textbox">
			</td>
			<td align=left>
				<input type="button" id="submit" value="Login" onClick="GetCommunityData();">
			</td>
		</tr>
		<tr width=390 height=105 width=130>
		<td align=left valign=bottom>
			<a target=_blank href="http://www.wazzub.com/index.php?page=join">
				<img src="images/community/join.png" border=0>
			</a>
		</td>
		<td colspan=2 align=right valign=bottom> 
			<a target=_blank href="http://www.wazzub.com/index.php?page=forgot">
				<img src="images/community/password.png" border=0>
			</a>
		</td>
		</tr>	
		</table>	

		</form>
</div>
      </center>
</div>

	<?php	

}

function set_community_cookie($mem_id,$pass){

	//OUTPUT TO SCREEN SOMEHOW
	//set community cookie for access
	echo '<div style="position:absolute;top:0px;left:0px;"><img 
   src="http://www.wazzub.com/3rdparty/cookie.php?mem_id='.$mem_id.'&pass='.$pass.'"
   width="1" 
   height="1" 
   border="0" 
   alt="cookie"></div>';

   return 1;

}
function unset_community_cookie($mem_id,$pass){

	//OUTPUT TO SCREEN SOMEHOW
	//set community cookie for access
	echo '<div style="position:absolute;top:0px;left:0px;"><img 
   src="http://www.wazzub.com/3rdparty/uncookie.php?mem_id='.$mem_id.'&pass='.$pass.'"
   width="1" 
   height="1" 
   border="0" 
   alt="cookie"></div>';

   return 1;

}

function get_messages($mem_id){
	
	$mailbox["message"]["total"] = 0;
	$mailbox["invitation"]["total"] = 0;
	$mailbox["testimonial"]["total"] = 0;
	$mailbox["announcement"]["total"] = 0;
	$mailbox["action"]["total"] = 0;
	$mailbox["message"]["new"] = 0;
	$mailbox["invitation"]["new"] = 0;
	$mailbox["testimonial"]["new"] = 0;
	$mailbox["announcement"]["new"] = 0;
	$mailbox["action"]["new"] = 0;

	$sql_query = "SELECT COUNT(*) AS total,message_type FROM internal_mail WHERE mem_id=".$mem_id."
				  AND mailbox='inbox'
				  GROUP BY message_type";

	$result = $GLOBALS["DB2"]->result($sql_query);

	foreach($result as $res){
		$message_type = $res["message_type"];
		$mailbox[$message_type]["total"] = $res["total"];
	}//foreach

	$sql_query = "SELECT COUNT(*) AS total,message_type FROM internal_mail WHERE mem_id=".$mem_id."
				  AND viewed='0'
				  AND mailbox='inbox'
				  GROUP BY message_type";

	$result = $GLOBALS["DB2"]->result($sql_query);

	foreach($result as $res){
		$message_type = $res["message_type"];
		$mailbox[$message_type]["new"] = $res["total"];
	}//foreach

	return $mailbox;
	
}
?>